<html>
<head>
<title>Viruses</title>
</head>

<body>

<center>
<h1>POI VII Stage 1 Problem 2</h1>
<h1>Viruses</h1>
</center>

<p>
Binary Viruses Investigation Committee detected, that certain sequences
of zeroes and ones are codes of viruses. The committee isolated a set
of all the virus codes. A sequence of zeroes and ones is called safe, if
any of its segments (i.e. sequence of consecutive elements) is not  
a virus code. The committee is aiming at finding, whether 
an infinite, safe sequence of zeroes and ones exists.
</p>

<h2>Example</h2>

<p>
For a set of codes {011, 11, 00000}, the sample infinite safe
sequence is 010101...&nbsp;. For a set of codes {01, 11, 00000} an
infinite safe sequence of zeroes and ones does not exist.
</p>

<h2>Task</h2>
<p>
Write a program, which:
<ul>
<li>reads virus codes from the text file WIR.IN,
<li>determines, whether an infinite, safe sequence of zeroes and
  ones exists
<li>writes the result to the text file WIR.OUT.
</ul>

<h2>Input</h2>

<p>
  The first line of the input file WIR.IN consists of one integer <i>n</i>
  standing for the number of all virus codes. Each of the next <i>n</i> lines
  consists of one non-empty word composed from 0s and 1s - a virus
  code. The total length of all words does not exceed 30000.
</p>

<h2>Output</h2>
<p>
In the first and the only line of the output file WIR.OUT one should find
a word:
<ul>
<li>TAK - if an infinite, safe sequence of zeroes and ones exists.
<li>NIE - otherwise.
</ul>

<h2>Sample Input</h2>
<pre>
3
01 
11 
00000
</pre>

<h2>Sample Output</h2>
<pre>
NIE
</pre>

</body>

</html>
